package main

import (
	"csswebdown/lib"
	"fmt"
)

func main() {
	fmt.Println("starting.....")
	start()
}

/*func start() {
	for i := 4000; i < 5000; i++ {
		url := "http://www.cssmoban.com/cssthemes/" + fmt.Sprint(i) + ".shtml"
		//fmt.Println(url)
		filename, downloadUrl := lib.SearchName(url)
		lib.Downlaod(downloadUrl, filename)
	}
}
*/
func start() {
	//build("http://sc.chinaz.com/moban/index_3.html")
	for i := 4; i < 60; i++ {
		url := "http://sc.chinaz.com/moban/index_" + fmt.Sprint(i) + ".html"
		build(url)
	}
}
func build(url string) {
	page := lib.GetURl(url)
	for _, item := range page {
		lib.Mkdir(lib.Basedir + item.Filename)
		lib.Downlaod(item.Img, item.Filename)
		down(item.FitUrl, item.Filename)
	}

}
func down(url, filename string) {
	durl := lib.Search_chinaz(url)
	lib.Downlaod(durl, filename)
}
